﻿#region << 文件说明 >>

/*----------------------------------------------------------------
 * 命名空间：Vampirewal.BlogCore.Attributes
 * 唯一标识：36f3341d-480a-445f-8144-8c5260cf7faf
 * 文件名：FormPropertyAttribute
 *
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2024/6/28 21:18:59
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

#endregion << 文件说明 >>

namespace Vampirewal.BlogCore;

/// <summary>
/// 标记为表单model
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public sealed class FormModelAttribute : Attribute
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="hasButton">是否包含按钮，默认没有</param>
    public FormModelAttribute(bool hasButton = false)
    {
        HasButton = hasButton;
    }

    /// <summary>
    /// 是否包含按钮
    /// </summary>
    internal bool HasButton { get; set; }
}

/// <summary>
/// 表单按钮特性
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class FormButtonAttribute : Attribute
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="label"></param>
    /// <param name="type"></param>
    /// <param name="excuteType"></param>
    /// <param name="methorName"></param>
    public FormButtonAttribute(string label, ButtonType type, ButtonExcuteType excuteType, string methorName)
    {
        Label = label;
        ButtonType = type;
        MethodName = methorName;
        ButtonExcuteType = excuteType;
    }

    /// <summary>
    /// 按钮标签
    /// </summary>
    internal string Label { get; set; }

    /// <summary>
    /// 按钮触发方法名称
    /// </summary>
    internal string MethodName { get; set; }

    /// <summary>
    /// 按钮类型
    /// </summary>
    internal ButtonType ButtonType { get; set; }

    /// <summary>
    /// 按钮执行方式类型
    /// </summary>
    internal ButtonExcuteType ButtonExcuteType { get; set; }
}

/// <summary>
/// 表单属性特性
/// </summary>
public abstract class FormPropertyAttribute : Attribute
{
    /// <summary>
    /// 标签
    /// </summary>
    public string Label { get; set; }
}

/// <summary>
/// 表单文本输入框属性特性
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class FormInputAttribute : FormPropertyAttribute
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="label"></param>
    /// <param name="watermark"></param>
    public FormInputAttribute(string label, string watermark = "")
    {
        Label = label;
        Watermark = watermark;
        InputType =  InputTypeEnum.Text;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="label"></param>
    /// <param name="watermark"></param>
    /// <param name="rowCount"></param>
    public FormInputAttribute(string label, string watermark = "",int rowCount=2)
    {
        Label = label;
        Watermark = watermark;
        InputType = InputTypeEnum.TextArea;
        RowCount=rowCount;
    }

    /// <summary>
    /// 水印
    /// </summary>
    internal string Watermark { get; set; }

    /// <summary>
    /// 文本框类型
    /// </summary>
    internal InputTypeEnum InputType { get; set; }

    /// <summary>
    /// 文本域的时候行数量
    /// </summary>
    internal int RowCount { get; set; }
}

/// <summary>
/// 表单数字输入框属性特性
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class FormNumInputAttribute : FormPropertyAttribute
{
    /// <summary>
    /// 数字输入框
    /// </summary>
    /// <param name="label"></param>
    /// <param name="min"></param>
    /// <param name="max"></param>
    /// <param name="precision"></param>
    /// <param name="step"></param>
    public FormNumInputAttribute(string label, int min, int max, int precision, float step)
    {
        Label = label;
        Min = min;
        Max = max;
        Precision = precision;
        Step = step;
    }

    /// <summary>
    /// 最小值
    /// </summary>
    internal int Min { get; set; }

    /// <summary>
    /// 最大值
    /// </summary>
    internal int Max { get; set; }

    /// <summary>
    /// 精度
    /// </summary>
    internal int Precision { get; set; }

    /// <summary>
    /// 步进
    /// </summary>
    internal float Step { get; set; }
}